#include <bits/stdc++.h>

using namespace std;
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3f;

int a[4][5] = { {1,1,0,0,0},{0,1,1,0,0},{1,0,1,1,0},{0,0,0,1,1} };

void solve()
{
    int N;
    cin >> N;
    int n = 30 * 4;
    vector<vector<int>> ans(n, vector<int>(n, 0));
    for (int row = 1, col = 0; col < n && row < n; row += 4, col += 4)
    {
        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 5; j++)
            {
                if (row + i < n && col + j < n)
                    ans[row + i][col + j] = a[i][j];
            }
        }
    }
    for (int i = 0; i < 30; i++)
    {
        if ((N >> i) & 1) ans[0][i * 4] = 1;
    }
    cout << n << endl;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++) cout << ans[i][j] << ' ';
        cout << endl;
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    //cin >> _;
    while (_--)
    {
        solve();
    }
    return 0;
}